import 'package:submail_one_login_flutter/model/base_sub_result.dart';

class ResultModel<T extends BaseSubResult> {
  bool isSuccess;
  T? result;

  ResultModel({required this.isSuccess, this.result});

  factory ResultModel.froSuccess(bool success, T result) {
    return ResultModel(isSuccess: success, result: result);
  }

  factory ResultModel.success(T result) {
    return ResultModel(isSuccess: true, result: result);
  }

  factory ResultModel.error(T? result) {
    return ResultModel(isSuccess: false, result: result);
  }

  Map<String, dynamic> toJson() {
    return {
      'isSuccess': isSuccess,
      'result': result,
    };
  }
}
